package com.frxuexi.task.repository

import com.frxuexi.lib_base.room.Task
import com.frxuexi.lib_base.room.TaskDao
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

@OptIn
class TaskRepository @Inject constructor(private val taskDao: TaskDao){

    fun commitTask(task: Task):Flow<Long>{
        return flow { emit(taskDao.insert(task)) }
    }

    fun getTasks():Flow<List<Task>?>{
        return flow { emit(taskDao.queryNoApprove()) }
    }

    fun approveTask(task: Task):Flow<Int>{
        return flow { emit(taskDao.update(task)) }
    }
}